<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>糖尿病预测结果</title>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#165DFF',
                        secondary: '#36BFFA',
                        accent: '#7B61FF',
                        success: '#00B42A',
                        warning: '#FF7D00',
                        danger: '#F53F3F',
                        dark: '#1D2129',
                        'gray-light': '#F2F3F5',
                        'gray-medium': '#C9CDD4',
                        'gray-dark': '#86909C',
                    },
                    fontFamily: {
                        inter: ['Inter', 'sans-serif'],
                    },
                }
            }
        }
    </script>
    <style type="text/tailwindcss">
        @layer utilities {
            .content-auto {
                content-visibility: auto;
            }
            .card-shadow {
                box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.02);
            }
            .input-focus {
                @apply focus:ring-2 focus:ring-primary/50 focus:border-primary transition-all duration-300;
            }
            .bg-gradient-primary {
                background: linear-gradient(135deg, #165DFF 0%, #7B61FF 100%);
            }
            .text-gradient {
                background-clip: text;
                -webkit-background-clip: text;
                color: transparent;
                background-image: linear-gradient(135deg, #165DFF 0%, #7B61FF 100%);
            }
            .form-input-wrapper {
                @apply relative;
            }
            .form-icon {
                @apply absolute inset-y-0 left-0 flex items-center pl-3 text-gray-dark pointer-events-none;
            }
            .form-input {
                @apply w-full pl-10 pr-4 py-3 rounded-lg border border-gray-medium input-focus;
            }
            .form-select {
                @apply w-full pl-10 pr-10 py-3 rounded-lg border border-gray-medium input-focus appearance-none;
            }
            .select-arrow {
                @apply absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none text-gray-dark;
            }
            .card-hover {
                @apply transition-all duration-300 hover:shadow-lg hover:-translate-y-1;
            }
            .card-badge {
                @apply absolute -top-3 -right-3 w-16 h-16 rounded-full flex items-center justify-center text-white font-bold shadow-lg;
            }
            .stat-card {
                @apply bg-white rounded-xl p-5 shadow-sm card-hover relative overflow-hidden;
            }
            .stat-card::before {
                content: '';
                @apply absolute top-0 left-0 w-full h-1;
            }
            .stat-card.bmi::before { @apply bg-blue-500; }
            .stat-card.smoking::before { @apply bg-orange-500; }
            .stat-card.heart::before { @apply bg-red-500; }
            .stat-card.hypertension::before { @apply bg-pink-500; }
            .stat-card.general::before { @apply bg-indigo-500; }
        }
    </style>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Inter', sans-serif;
        }

        body {
            background-color: #f8fafc;
        }

        nav {
            position: fixed;
            top: 0;
            width: 100%;
            background: white;
            padding: 1rem 2rem;
            box-shadow: 0 2px 10px rgba(0,0,0,0.05);
            z-index: 100;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 2rem;
        }

        .nav-content {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .logo {
            color: #1A73E8;
            font-size: 1.5rem;
            font-weight: bold;
        }

        .nav-links a {
            color: #5f6368;
            margin-left: 2rem;
            text-decoration: none;
            transition: color 0.3s;
        }

        .nav-links a:hover {
            color: #1A73E8;
        }

        main {
            margin-top: 80px;
            padding: 4rem 2rem;
        }

        .result-header {
            text-align: center;
            margin-bottom: 4rem;
        }

        .result-title {
            color: #1A73E8;
            font-size: 2.5rem;
            font-weight: bold;
            margin-bottom: 1rem;
        }

        .result-subtitle {
            color: #5f6368;
            font-size: 1.1rem;
        }

        .core-result {
            text-align: center;
            margin-bottom: 3rem;
        }

        .risk-score {
            color: #FF4444;
            font-size: 3rem;
            font-weight: bold;
        }

        /* 新增美化样式 */
        .dashboard-card {
            background: white;
            border-radius: 20px;
            padding: 2rem;
            box-shadow: 0 10px 30px rgba(0,0,0,0.05);
            transition: all 0.3s ease;
            position: relative;
        }

        .dashboard-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 15px 35px rgba(0,0,0,0.1);
        }

        .analysis-card {
            background: white;
            border-radius: 15px;
            padding: 2rem;
            box-shadow: 0 4px 12px rgba(0,0,0,0.05);
            margin-bottom: 2rem;
            transition: all 0.3s ease;
            border-left: 4px solid;
        }

        .analysis-card:hover {
            transform: translateY(-3px);
            box-shadow: 0 8px 20px rgba(0,0,0,0.08);
        }

        .card-header {
            display: flex;
            align-items: center;
            gap: 1rem;
            margin-bottom: 1.5rem;
        }

        .card-icon {
            width: 48px;
            height: 48px;
            border-radius: 50%;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 1.4rem;
            box-shadow: 0 4px 12px rgba(0,0,0,0.1);
        }

        .card-icon.bmi { background: #1A73E81A; color: #1A73E8; }
        .card-icon.smoking { background: #FF98001A; color: #FF9800; }
        .card-icon.heart { background: #FF44441A; color: #FF4444; }
        .card-icon.hypertension { background: #FF6B6B1A; color: #FF6B6B; }
        .card-icon.general { background: #1A73E81A; color: #1A73E8; }

        .card-title {
            font-size: 1.3rem;
            color: #333;
            font-weight: 600;
        }

        .card-content {
            color: #5f6368;
            line-height: 1.6;
        }

        .recommendation-card {
            background: #f8f9fa;
            border-radius: 10px;
            padding: 1.5rem;
            margin-top: 1.5rem;
            border-left: 4px solid;
            transition: all 0.3s ease;
        }

        .recommendation-card:hover {
            box-shadow: 0 4px 12px rgba(0,0,0,0.05);
        }

        .recommendation-title {
            font-size: 1.1rem;
            font-weight: 600;
            margin-bottom: 1rem;
        }

        .recommendation-list {
            list-style: none;
        }

        .recommendation-item {
            margin-bottom: 0.8rem;
            display: flex;
            align-items: flex-start;
            transition: all 0.2s ease;
        }

        .recommendation-item:hover {
            transform: translateX(3px);
        }

        .recommendation-item i {
            color: inherit;
            margin-right: 0.8rem;
            margin-top: 0.2rem;
        }

        .action-buttons {
            text-align: center;
            margin-top: 3rem;
        }

        .button {
            display: inline-block;
            padding: 1rem 2rem;
            border-radius: 25px;
            text-decoration: none;
            font-weight: 500;
            transition: all 0.3s;
            box-shadow: 0 4px 12px rgba(0,0,0,0.1);
        }

        .button-primary {
            background: #1A73E8;
            color: white;
        }

        .button-primary:hover {
            background: #1556b0;
            transform: translateY(-2px);
            box-shadow: 0 6px 16px rgba(26, 115, 232, 0.2);
        }

        .button-secondary {
            background: #f0f2f5;
            color: #5f6368;
            margin-left: 1rem;
        }

        .button-secondary:hover {
            background: #e5e7eb;
            transform: translateY(-2px);
            box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
        }


        /* 动画效果 */
        .fade-in {
            animation: fadeIn 0.5s ease-in-out;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .stat-value {
            font-size: 1.5rem;
            font-weight: bold;
            margin-bottom: 0.5rem;
        }

        /* 进度条样式 */
        .progress-bar {
            height: 8px;
            border-radius: 4px;
            background-color: #e2e8f0;
            overflow: hidden;
            margin-top: 1rem;
        }

        .progress-value {
            height: 100%;
            border-radius: 4px;
            transition: width 1s ease-in-out;
        }
    </style>
</head>
<body class="font-inter bg-gray-light min-h-screen flex flex-col">
    <!-- 导航栏 -->
    <nav class="bg-gradient-to-r from-blue-600 to-indigo-600 text-white p-4 h-16 shadow-md">
        <div class="container mx-auto flex justify-between items-center">
            <h1 class="text-2xl font-bold flex items-center">
                <i class="fa-solid fa-heartbeat mr-2"></i>
                糖尿病预测结果
            </h1>
            <ul class="flex space-x-4">
                <li><a href="{{ url_for('home') }}" class="hover:text-gray-200 transition-colors duration-300">
                    <i class="fa-solid fa-home mr-1"></i> 首页
                </a></li>
                <li><a href="{{ url_for('index') }}" class="hover:text-gray-200 transition-colors duration-300">
                    <i class="fa-solid fa-calculator mr-1"></i> 重新评估
                </a></li>
            </ul>
        </div>
    </nav>

    <main class="fade-in">
        <div class="container">
            <div class="result-header">
                <h1 class="result-title text-gradient">糖尿病风险评估结果</h1>
                <p class="result-subtitle">以下分析基于您的健康数据，仅供参考</p>
            </div>

            <div class="dashboard-card">
                <!-- 核心结果 -->
                <div class="core-result">
                    {% if diabetes == 1 %}
                        <div class="inline-block bg-red-50 border-l-4 border-red-400 text-red-700 p-4 rounded-lg mb-4">
                            <div class="flex items-center">
                                <i class="fa-solid fa-exclamation-triangle text-2xl mr-3"></i>
                                <div>
                                    <h2>风险提示：您有<span class="risk-score">{{ probability }}%</span> 概率可能患糖尿病</h2>
                                    <p class="result-subtitle mt-1">建议尽快进行专业医学检查</p>
                                </div>
                            </div>
                        </div>
                    {% else %}
                        <div class="inline-block bg-green-50 border-l-4 border-green-400 text-green-700 p-4 rounded-lg mb-4">
                            <div class="flex items-center">
                                <i class="fa-solid fa-check-circle text-2xl mr-3"></i>
                                <div>
                                    <h2>评估结果：<span class="risk-score text-green-500">低风险</span></h2>
                                    <p class="result-subtitle mt-1">请继续保持健康生活方式</p>
                                </div>
                            </div>
                        </div>
                    {% endif %}

                    <!-- 风险进度条 -->
                    <div class="max-w-md mx-auto mt-6">
                        <div class="text-sm text-gray-600 mb-1">糖尿病风险程度</div>
                        <div class="progress-bar">
                            <div class="progress-value bg-gradient-to-r from-green-500 via-yellow-500 to-red-500"
                                 data-target-width="{{ probability }}%"
                                 style="width: {{ probability }}%"></div>
                        </div>
                        <div class="flex justify-between text-xs text-gray-500 mt-1">
                            <span>低风险</span>
                            <span>中等风险</span>
                            <span>高风险</span>
                        </div>
                    </div>
                </div>

                <!-- 指标分析卡片 -->
                <div class="grid grid-cols-1 md:grid-cols-2 gap-6 mt-8">
                    <!-- BMI分析 -->
                    <div class="analysis-card bmi" style="border-color: #1A73E8;">
                        <div class="card-header">
                            <div class="card-icon bmi"><i class="fa-solid fa-balance-scale"></i></div>
                            <div class="card-title">BMI分析（{{ bmi }}）</div>
                        </div>
                        <div class="card-content">
                            {% if bmi < 18.5 %}
                                <span class="text-yellow-500 font-semibold">体重过轻</span> | 建议增加蛋白质摄入（如鸡蛋、牛奶）
                            {% elif bmi >= 18.5 and bmi < 24 %}
                                <span class="text-green-500 font-semibold">正常</span> | 保持均衡饮食（谷物+蔬菜+蛋白质）
                            {% elif bmi >= 24 and bmi < 28 %}
                                <span class="text-yellow-500 font-semibold">超重</span> | 控制高热量食物，增加运动
                            {% else %}
                                <span class="text-red-500 font-semibold">肥胖</span> | 建议咨询营养师制定减重计划
                            {% endif %}

                            <!-- BMI健康建议 -->
                            <div class="recommendation-card" style="border-color: #1A73E8;">
                                <div class="recommendation-title text-blue-600">
                                    <i class="fa-solid fa-lightbulb mr-2"></i>个性化健康建议
                                </div>
                                <ul class="recommendation-list">
                                    {% if bmi < 18.5 %}
                                        <li class="recommendation-item text-blue-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            每日增加1-2份优质蛋白质，如鸡胸肉、鱼类或豆制品
                                        </li>
                                        <li class="recommendation-item text-blue-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            选择健康脂肪，如坚果、牛油果和橄榄油
                                        </li>
                                        <li class="recommendation-item text-blue-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            分5-6餐进食，避免一次性摄入过多
                                        </li>
                                    {% elif bmi >= 24 %}
                                        <li class="recommendation-item text-blue-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            减少精制碳水化合物（如白米饭、面包）的摄入
                                        </li>
                                        <li class="recommendation-item text-blue-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            每周进行至少150分钟中等强度有氧运动
                                        </li>
                                        <li class="recommendation-item text-blue-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            控制餐量，使用较小的餐盘有助于减少进食量
                                        </li>
                                    {% else %}
                                        <li class="recommendation-item text-blue-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            保持每日膳食中50%以上为蔬菜和水果
                                        </li>
                                        <li class="recommendation-item text-blue-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            每周进行3-4次力量训练，维持肌肉量
                                        </li>
                                        <li class="recommendation-item text-blue-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            定期监测体重，保持健康波动范围
                                        </li>
                                    {% endif %}
                                </ul>
                            </div>
                        </div>
                    </div>

                    <!-- 吸烟史分析 -->
                    <div class="analysis-card smoking" style="border-color: #FF9800;">
                        <div class="card-header">
                            <div class="card-icon smoking"><i class="fa-solid fa-smoking"></i></div>
                            <div class="card-title">吸烟史（{{ smoking_history }}）</div>
                        </div>
                        <div class="card-content">
                            {% if smoking_history == 0 %}
                                <span class="text-green-500 font-semibold">从未吸烟</span> | 优秀习惯，继续保持！
                            {% elif smoking_history == 1 %}
                                <span class="text-red-500 font-semibold">当前吸烟</span> | 吸烟会增加糖尿病风险，建议立即戒烟
                            {% elif smoking_history == -1 %}
                                <span class="text-yellow-500 font-semibold">已戒烟</span> | 坚持远离烟草，降低并发症风险
                            {% else %}
                                <span class="text-gray-600 font-semibold">未知</span> | 建议记录吸烟情况，避免被动吸烟
                            {% endif %}

                            <!-- 吸烟健康建议 -->
                            <div class="recommendation-card" style="border-color: #FF9800;">
                                <div class="recommendation-title text-orange-600">
                                    <i class="fa-solid fa-lightbulb mr-2"></i>吸烟相关建议
                                </div>
                                <ul class="recommendation-list">
                                    {% if smoking_history == 1 %}
                                        <li class="recommendation-item text-orange-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            制定戒烟计划，可寻求医生或戒烟热线帮助
                                        </li>
                                        <li class="recommendation-item text-orange-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            记录每日吸烟量，逐步减少
                                        </li>
                                        <li class="recommendation-item text-orange-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            用无糖口香糖或健康零食替代吸烟习惯
                                        </li>
                                    {% elif smoking_history == -1 %}
                                        <li class="recommendation-item text-orange-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            恭喜您成功戒烟！继续保持，降低健康风险
                                        </li>
                                        <li class="recommendation-item text-orange-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            避免接触二手烟环境，保护呼吸系统
                                        </li>
                                        <li class="recommendation-item text-orange-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            定期进行肺部健康检查
                                        </li>
                                    {% else %}
                                        <li class="recommendation-item text-orange-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            继续保持无烟生活，降低多种疾病风险
                                        </li>
                                        <li class="recommendation-item text-orange-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            注意避免被动吸烟，保护家人健康
                                        </li>
                                    {% endif %}
                                </ul>
                            </div>
                        </div>
                    </div>

                    <!-- 心脏病史分析 -->
                    <div class="analysis-card heart" style="border-color: #FF4444;">
                        <div class="card-header">
                            <div class="card-icon heart"><i class="fa-solid fa-heart-pulse"></i></div>
                            <div class="card-title">心脏病史（{{ heart_disease}}）</div>
                        </div>
                        <div class="card-content">
                            {% if heart_disease == 0 %}
                                <span class="text-green-500 font-semibold">无</span> | 保持健康习惯，定期体检
                            {% else %}
                                <span class="text-red-500 font-semibold">有</span> | 密切监测血糖血压，遵循医嘱治疗
                            {% endif %}

                            <!-- 心脏健康建议 -->
                            <div class="recommendation-card" style="border-color: #FF4444;">
                                <div class="recommendation-title text-red-600">
                                    <i class="fa-solid fa-lightbulb mr-2"></i>心脏健康管理
                                </div>
                                <ul class="recommendation-list">
                                    {% if heart_disease == 0 %}
                                        <li class="recommendation-item text-red-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            保持健康饮食，减少饱和脂肪和胆固醇摄入
                                        </li>
                                        <li class="recommendation-item text-red-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            每周进行至少150分钟中等强度有氧运动
                                        </li>
                                        <li class="recommendation-item text-red-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            定期检查血压、血脂等心脏相关指标
                                        </li>
                                    {% else %}
                                        <li class="recommendation-item text-red-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            严格遵循医生开具的药物治疗方案
                                        </li>
                                        <li class="recommendation-item text-red-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            每日监测并记录血压和心率
                                        </li>
                                        <li class="recommendation-item text-red-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            避免剧烈运动，在医生指导下进行适当锻炼
                                        </li>
                                        <li class="recommendation-item text-red-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            控制情绪，避免过度紧张和焦虑
                                        </li>
                                    {% endif %}
                                </ul>
                            </div>
                        </div>
                    </div>

                    <!-- 高血压史分析 -->
                    <div class="analysis-card hypertension" style="border-color: #FF6B6B;">
                        <div class="card-header">
                            <div class="card-icon hypertension"><i class="fa-solid fa-stethoscope"></i></div>
                            <div class="card-title">高血压史（{{ hypertension}}）</div>
                        </div>
                        <div class="card-content">
                            {% if hypertension == 0 %}
                                <span class="text-green-500 font-semibold">无</span> | 保持低盐饮食，定期监测血压
                            {% else %}
                                <span class="text-red-500 font-semibold">有</span> | 严格控制钠盐摄入，遵医嘱服药，定期监测血压
                            {% endif %}

                            <!-- 高血压健康建议 -->
                            <div class="recommendation-card" style="border-color: #FF6B6B;">
                                <div class="recommendation-title text-pink-600">
                                    <i class="fa-solid fa-lightbulb mr-2"></i>血压管理建议
                                </div>
                                <ul class="recommendation-list">
                                    {% if hypertension == 0 %}
                                        <li class="recommendation-item text-pink-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            每日盐摄入量不超过5克，减少加工食品摄入
                                        </li>
                                        <li class="recommendation-item text-pink-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            增加钾摄入，多吃香蕉、菠菜等富含钾的食物
                                        </li>
                                        <li class="recommendation-item text-pink-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            定期进行血压自我监测，建议每周1-2次
                                        </li>
                                    {% else %}
                                        <li class="recommendation-item text-pink-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            严格遵循医生开具的降压药物治疗方案
                                        </li>
                                        <li class="recommendation-item text-pink-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            每日盐摄入量控制在3克以内，避免酱油、腌制品
                                        </li>
                                        <li class="recommendation-item text-pink-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            每天早晚各测量一次血压并记录
                                        </li>
                                        <li class="recommendation-item text-pink-700">
                                            <i class="fa-solid fa-check-circle"></i>
                                            建议每天进行30分钟以上的有氧运动，如快走、游泳
                                        </li>
                                    {% endif %}
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 综合健康建议 -->
                <div class="analysis-card general mt-6" style="border-color: #7B61FF;">
                    <div class="card-header">
                        <div class="card-icon general"><i class="fa-solid fa-heartbeat"></i></div>
                        <div class="card-title">综合健康建议</div>
                    </div>
                    <div class="card-content grid grid-cols-1 md:grid-cols-3 gap-6">
                        <!-- 生活方式 -->
                        <div class="recommendation-card" style="border-color: #7B61FF;">
                            <div class="recommendation-title text-indigo-600">
                                <i class="fa-solid fa-moon mr-2"></i>生活方式调整
                            </div>
                            <ul class="recommendation-list">
                                <li class="recommendation-item text-indigo-700">
                                    <i class="fa-solid fa-check-circle"></i>
                                    每日保证7-8小时高质量睡眠，建立规律作息时间
                                </li>
                                <li class="recommendation-item text-indigo-700">
                                    <i class="fa-solid fa-check-circle"></i>
                                    减少久坐时间，每小时起身活动5分钟
                                </li>
                                <li class="recommendation-item text-indigo-700">
                                    <i class="fa-solid fa-check-circle"></i>
                                    管理压力，可通过冥想、瑜伽或爱好缓解压力
                                </li>
                            </ul>
                        </div>

                        <!-- 饮食建议 -->
                        <div class="recommendation-card" style="border-color: #00B42A;">
                            <div class="recommendation-title text-green-600">
                                <i class="fa-solid fa-utensils mr-2"></i>饮食建议
                            </div>
                            <ul class="recommendation-list">
                                <li class="recommendation-item text-green-700">
                                    <i class="fa-solid fa-check-circle"></i>
                                    增加膳食纤维摄入，推荐每日25-30克
                                </li>
                                <li class="recommendation-item text-green-700">
                                    <i class="fa-solid fa-check-circle"></i>
                                    选择低升糖指数（GI）食物，如燕麦、全麦面包
                                </li>
                                <li class="recommendation-item text-green-700">
                                    <i class="fa-solid fa-check-circle"></i>
                                    限制添加糖摄入，每日不超过25克
                                </li>
                                <li class="recommendation-item text-green-700">
                                    <i class="fa-solid fa-check-circle"></i>
                                    每日饮水1500-2000毫升，建议饮用白开水或淡茶水
                                </li>
                            </ul>
                        </div>

                        <!-- 运动建议 -->
                        <div class="recommendation-card" style="border-color: #FF9800;">
                            <div class="recommendation-title text-orange-600">
                                <i class="fa-solid fa-dumbbell mr-2"></i>运动建议
                            </div>
                            <ul class="recommendation-list">
                                <li class="recommendation-item text-orange-700">
                                    <i class="fa-solid fa-check-circle"></i>
                                    每周进行至少150分钟中等强度有氧运动，如快走、骑自行车
                                </li>
                                <li class="recommendation-item text-orange-700">
                                    <i class="fa-solid fa-check-circle"></i>
                                    每周2-3次力量训练，包括抗阻练习（如哑铃、弹力带）
                                </li>
                                <li class="recommendation-item text-orange-700">
                                    <i class="fa-solid fa-check-circle"></i>
                                    运动前后进行5-10分钟热身和拉伸，避免受伤
                                </li>
                                <li class="recommendation-item text-orange-700">
                                    <i class="fa-solid fa-check-circle"></i>
                                    血糖不稳定者运动时应携带糖果，预防低血糖
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>

                <!-- 操作按钮 -->
                <div class="action-buttons">
                    <a href="{{ url_for('index') }}" class="button button-primary">
                        <i class="fa-solid fa-redo mr-1"></i> 重新评估
                    </a>
                    <button onclick="downloadResults()" class="button button-secondary">
                        <i class="fa-solid fa-download mr-1"></i> 下载文本报告
                    </button>
                </div>
            </div>
        </div>
    </main>

    <script>
        // 页面加载动画
        document.addEventListener('DOMContentLoaded', function() {
            // 为进度条添加动画效果
            const progressBars = document.querySelectorAll('.progress-value');
            progressBars.forEach(bar => {
                // 从data属性获取目标宽度
                const targetWidth = bar.getAttribute('data-target-width');

                // 重置宽度为0%开始动画
                bar.style.width = '0%';

                // 应用过渡效果
                bar.style.transition = 'width 1s ease-in-out';

                // 延迟后应用目标宽度
                setTimeout(() => {
                    bar.style.width = targetWidth;
                }, 100);
            });

            // 为卡片添加淡入动画
            const cards = document.querySelectorAll('.analysis-card');
            cards.forEach((card, index) => {
                card.style.opacity = '0';
                card.style.transform = 'translateY(20px)';
                setTimeout(() => {
                    card.style.transition = 'opacity 0.5s ease, transform 0.5s ease';
                    card.style.opacity = '1';
                    card.style.transform = 'translateY(0)';
                }, 200 + (index * 100));
            });
        });

        // 优化后的文本下载功能
        function downloadResults() {
            // 显示加载状态
            const originalText = event.currentTarget.innerHTML;
            event.currentTarget.innerHTML = '<i class="fa-solid fa-spinner fa-spin mr-1"></i> 生成中...';
            event.currentTarget.disabled = true;

            // 提取核心结果
            const resultElement = document.querySelector('.core-result h2');
            const resultText = resultElement ? resultElement.innerText : '风险评估结果';

            // 提取风险概率
            const probabilityElement = document.querySelector('.risk-score');
            const probabilityText = probabilityElement ? probabilityElement.innerText : '未知';

            // 提取所有建议
            let recommendations = '';
            document.querySelectorAll('.recommendation-list').forEach(list => {
                list.querySelectorAll('li').forEach(item => {
                    recommendations += `- ${item.innerText}\n`;
                });
                recommendations += '\n';
            });

            // 生成文本内容
            const timestamp = new Date().toLocaleString();
            const content = `
糖尿病风险评估报告
生成时间: ${timestamp}

${resultText}
风险概率: ${probabilityText}

健康建议:
${recommendations}
            `.trim();

            // 创建并下载文件
            const blob = new Blob([content], { type: 'text/plain;charset=utf-8' });
            const link = document.createElement('a');
            link.href = URL.createObjectURL(blob);
            link.download = `糖尿病风险评估摘要_${new Date().toISOString().slice(0, 19).replace(/:/g, '-')}.txt`;
            link.click();

            // 恢复按钮状态
            setTimeout(() => {
                event.currentTarget.innerHTML = originalText;
                event.currentTarget.disabled = false;
            }, 1000);
        }
    </script>
</body>
</html>